package com.dmc.scrabblator;

import java.io.File;
import java.util.List;
import java.util.Set;

public class WordFinder
{

	//Serialize Trie??
    //Remove initial point'ing? The WordRule will re-do it..
	//Handle blanks!!
    //Problem with ?2?b??:abba - want the a on the 2 but can match to multiple positions.
	//Bug - returning multiple BIDED with different values.   (NOT A BUG - all about the blank getting up in other's bidness)

	public static void main(String[] args)
	{
		//File f = new File("G:/corncob_lowercase.txt");
	    File f = new File("G:/workspace/Scrabblator/DictionaryNewLine.txt");
	    //File f = new File("C:/workspace/WordFinder/DictionaryNewLine.txt");
	    
		WordManager wm = new WordManager();
		try
		{
			wm.generate(f);
		}
		catch (Exception e)
		{
			System.err.println(e.getMessage());
			e.printStackTrace();
			System.exit(1);
		}
		//TODO: Currently have to add the letters in Positions to the serach term.. change that?
		Set<WordValue> strings = wm.search("RTROEIB");//RTRDEIB : birder=10
		WordRule rule = new WordRule();
		List<Character> positions = WordValueUtil.stringToCharList("???0???");//"?2?D4?"
		rule.setRule(positions);
		for (WordValue s : strings)
		{
			System.out.print(s);
			System.out.print("\t");
			System.out.print(rule.applyRule(s)); 
			System.out.println();
		}
		
		Set<WordValue> ruledWords = rule.applyRule(strings);
		for (WordValue s : ruledWords)
		{
			System.out.println(s);
		}
		
		
	}

}
